﻿<%@ Page Language="C#" MasterPageFile="~/Site_SignPage.Master" AutoEventWireup="true" CodeBehind="FilterCustomize.aspx.cs" Inherits="ERPTemplate.Public.CustomFilter" Title="设置过滤条件" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head_in" runat="server">
     <style type="text/css">
        .MainDiv
        {
        }
        .DataList_Filter
        {     
            width:100%;
        } 
        .DataList_Sort
        {    
            width:100%;
        }
        .f_td1
        {
            width:15%;
            text-align:center;
        }
        .f_td2
        {  
            width:15%;
            text-align:center;
        }
        .f_td3
        {   
            width:15%;
            text-align:center;
        }
        .f_td4
        {    
            width:15%;
            text-align:center;
        }
        .f_td5
        { 
            width:25%;
            text-align:center;
        } 
        .f_td6
        {  
            width:15%;
            text-align:center;
        } 
        .Table_Filter
        {
            width:100%;
        }  
        .addData_Filter,.addData_Sort
        {  
            background:url(/images/add-button.png) no-repeat;
            text-decoration:none;
            width:117px;
            height:23px;
            line-height:23px;
            padding:4px 8px 4px 30px; 
            font-size:small;
                           
        }         
        .OperatorAnchor_editData_S,.OperatorAnchor_editData_F
        {  
            cursor:pointer ;
            color:Blue;
            font-size:small ;
            background:url(/Images/dialog-operate.png) no-repeat -23px -51px;
            width:23px;
            height:17px;
            line-height:17px;
            text-indent:-9999em;
            display:block;
        }  
        .OperatorAnchor_editData_S:hover,  .OperatorAnchor_editData_F:hover
        {    
            background-position:0px -51px; 
        }  
        .OperatorAnchor_deleteData_S,.OperatorAnchor_deleteData_F
        {  
            cursor:pointer ;
            color:Blue;
            font-size:small ;
            background:url(/Images/dialog-operate.png) no-repeat -23px 0px;
            width:23px;
            height:17px;
            line-height:17px;
            text-indent:-9999em;
            display:block;
        }  
        .OperatorAnchor_deleteData_S:hover , .OperatorAnchor_deleteData_F:hover
        {    
            background-position:0px 0px; 
        } 
        .DataListHeader ,.DataList_Footer
        {
            background-color:#E3E3E3;  
            margin:2px 0px 2px 0px;
        }
        .DataList_Sort .Table_Filter ,.DataList_Filter .Table_Filter 
        {
            border-bottom:dashed 1px #E3E3E3;
            margin:2px 0px 2px 0px;
        }
     </style>
    <link href="/Css/dhtmlwindow.css" rel="stylesheet" type="text/css" />
    <link href="/Css/rulcode.css" rel="stylesheet" type="text/css" />
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder_in" runat="server">
    <div class="MainDiv"> 
        <div id="ModifyQueryDiv" runat="server">
            <b>修改Query:</b><span id="OldQueryNameSpan" runat="server"></span>
        </div>
        <div id="NewQueryDiv" runat="server"> 
            新建Query:  <b id="QueryNameB" runat="server"></b>   <br />
            <span>Query的新名称：</span>
            <asp:TextBox ID="TextBox_QueryName" CssClass="QueryNameInput" Width="200px" runat="server"></asp:TextBox>
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <asp:Button ID="Button_ModifyQueryName"  runat="server" Text="新建" 
                onclick="Button_ModifyQueryName_Click" />        
        </div> 
        <input id="CurrentQueryName" class="CurrentQueryName" runat="server" type="hidden"/>                   
        <hr />
        <br />           
        <fieldset>
            <legend>设置排序方式</legend> 
            <div class="DataListHeader">
            <table class="Table_Filter">
                <tr>                     
                    <td class="f_td1">表名</td>
                    <td class="f_td2">字段名</td>
                    <td class="f_td3">排序方向</td>  
                    <td class="f_td4"></td>
                    <td class="f_td5"></td>  
                    <td class="f_td6"></td>
                </tr>
            </table> 
            </div>
            <asp:DataList ID="DataList_Sort" CssClass="DataList_Sort"  runat="server">
                <ItemTemplate>                      
                    <table  class="Table_Filter">
                        <tr>                     
                            <td class="f_td1"><%#Eval("表名").ToString()%></td>
                            <td class="f_td2"><%#Eval("字段名").ToString()%></td>
                            <td class="f_td3"><%#Eval("排序方向").ToString()%></td>  
                            <td class="f_td4"> 
                                <table>
                                    <tr>
                                        <td>
                                            <a href="#" refid='<%#Eval("ID").ToString() %>' title="修改" class="OperatorAnchor_editData_S">修改</a>
                                        </td>
                                        <td>                                                  
                                            <a href="#" refid='<%#Eval("ID").ToString() %>'   title="删除" class="OperatorAnchor_deleteData_S">删除</a>
                                        </td>
                                    </tr>
                                </table>
                            </td>
                            <td class="f_td5"> &nbsp;</td> 
                            <td class="f_td6"> &nbsp;</td>
                        </tr>
                    </table> 
                </ItemTemplate>
            </asp:DataList> 
            <div class="DataList_Footer">
                 <a href="#" class="addData_Sort" title="增加排序方式">增加排序方式</a>
            </div>
            <br />    
        </fieldset>
        <br />
        <fieldset>
            <legend>设置过滤条件</legend>
            <div class="DataListHeader">
            <table class="Table_Filter">
                <tr>                     
                    <td class="f_td1">表名</td>
                    <td class="f_td2">字段名</td>
                    <td class="f_td3">过滤操作</td>  
                    <td class="f_td4">设置的值</td>
                    <td class="f_td5">过滤描述</td> 
                    <td class="f_td6"> </td>
                </tr>
            </table>
            </div> 
            <asp:DataList ID="DataList_Filter" CssClass="DataList_Filter"  runat="server">
                <ItemTemplate>                      
                    <table  class="Table_Filter">
                        <tr>                     
                            <td class="f_td1"><%#Eval("表名").ToString()%></td>
                            <td class="f_td2"><%#Eval("字段名").ToString()%></td>
                            <td class="f_td3"><%#Eval("过滤操作").ToString()%></td>  
                            <td class="f_td4"><%#Eval("设置的值").ToString()%></td>
                            <td class="f_td5"><%#Eval("设置描述").ToString()%></td>
                            <td class="f_td6"> 
                                <table>
                                    <tr>
                                        <td>
                                            <a href="#" refid='<%#Eval("ID").ToString() %>'   title="修改" class="OperatorAnchor_editData_F">修改</a>
                                        </td>
                                        <td>                                                  
                                            <a href="#" refid='<%#Eval("ID").ToString() %>'   title="删除" class="OperatorAnchor_deleteData_F">删除</a>
                                        </td>
                                    </tr>
                                </table>
                            </td>
                        </tr>
                    </table> 
                </ItemTemplate>
            </asp:DataList>                
            <div class="DataList_Footer">                   
                 <a href="#" class="addData_Filter" title="增加过滤条件">增加过滤条件</a>
            </div>
            <br />       
        </fieldset> 
        <br />
    </div>
    <script type="text/javascript">
        $(document).ready(function() {
            //删除过滤条件
            $(".OperatorAnchor_deleteData_F").click(function() {
                var queryName = getCurrentQueryName();
                var tablename = $.getQueryString("tablename");
                var id = $.getQueryString("id");
                var refid = $(this).attr("refid");
                if (refid != "") {
                    $.alerts.confirm("您确定要删除当前数据吗？", "确定删除", function(result) {
                        if (result) {
                            $.get("/Public/DeleteRecord.aspx?tablename=" + tablename + "&queryname=" + queryName + "&refid=" + refid + "&type=f&id=" + id, function(data) {
                                if (data.toString().toLowerCase() == "true") {
                                    $.alerts.alert("删除成功！", "成功", function() {
                                        jQuery.refresh();
                                    });
                                }
                                else {
                                    $.alerts.alert("删除失败", "失败");
                                }
                            })
                        }
                    })
                }
            });

            //编辑过滤条件
            $(".OperatorAnchor_editData_F").click(function() {
                var queryName = getCurrentQueryName();
                var tablename = $.getQueryString("tablename");
                var id = $.getQueryString("id");
                var refid = $(this).attr("refid");
                var isNew = ($.getQueryString("type")=="new");                
                if (queryName != "") {
                    dhtmlwindow.open('iframebox_editFilter', 'iframe', "UpdateFilter.aspx?type=edit&refid=" + refid + "&queryname=" + queryName + "&id=" + id + "&tablename=" + tablename, '编辑过滤条件', 'width=600px,height=350px,center=1,top=100px,resize=1,scrolling=1');
                }
            });

            //增加过滤条件
            $(".addData_Filter").click(function() {
                var queryName = getCurrentQueryName();
                var tablename = $.getQueryString("tablename");
                var id = $.getQueryString("id");
                var isNew = ($.getQueryString("type") == "new");
                if (queryName != "") {
                    dhtmlwindow.open('iframebox_addFilter', 'iframe', "UpdateFilter.aspx?type=new&queryname=" + queryName + "&id=" + id + "&tablename=" + tablename, '增加过滤条件', 'width=600px,height=350px,center=1,top=100px,resize=1,scrolling=1');
                }
            });

            //删除排序方式
            $(".OperatorAnchor_deleteData_S").click(function() {
                var queryName = getCurrentQueryName();
                var tablename = $.getQueryString("tablename");
                var id = $.getQueryString("id");
                var refid = $(this).attr("refid");
                if (refid != "") {
                    $.alerts.confirm("您确定要删除当前数据吗？", "确定删除", function(result) {
                        if (result) {
                            $.get("/Public/DeleteRecord.aspx?tablename=" + tablename + "&queryname=" + queryName + "&refid=" + refid + "&type=s&id=" + id, function(data) {
                                if (data.toString().toLowerCase() == "true") {
                                    $.alerts.alert("删除成功！", "成功", function() {
                                        jQuery.refresh();
                                    });
                                }
                                else {
                                    $.alerts.alert("删除失败", "失败");
                                }
                            })
                        }
                    })
                }
            });

            //编辑排序方式
            $(".OperatorAnchor_editData_S").click(function() {
                var queryName = getCurrentQueryName();
                var tablename = $.getQueryString("tablename");
                var id = $.getQueryString("id");
                var refid = $(this).attr("refid");
                if (queryName != "") {
                    dhtmlwindow.open('iframebox_editSort', 'iframe', "UpdateSort.aspx?type=edit&refid=" + refid + "&queryname=" + queryName + "&id=" + id + "&tablename=" + tablename, '编辑排序方式', 'width=600px,height=350px,center=1,top=100px,resize=1,scrolling=1');
                }
            });

            //增加排序方式
            $(".addData_Sort").click(function() {
                var queryName = getCurrentQueryName();
                var tablename = $.getQueryString("tablename");
                var id = $.getQueryString("id");
                if (queryName != "") {
                    dhtmlwindow.open('iframebox_addSort', 'iframe', "UpdateSort.aspx?type=new&queryname=" + queryName + "&id=" + id + "&tablename=" + tablename, '增加排序方式', 'width=600px,height=350px,center=1,top=100px,resize=1,scrolling=1');
                }
            });
        });

        function getCurrentQueryName() {
            var queryName = $(".CurrentQueryName").attr("value");
            if (queryName == "") {
                alert("对不起，请修改Query的名称");
                return "";
            }
            return queryName;
        }
    </script>
</asp:Content>
